package com.kin207.netty.listener.server.handle;

import java.util.Collection;
import java.util.List;

import com.kin207.netty.context.RequestContext;
import com.kin207.netty.handle.IMessageHandle;
import com.kin207.netty.listener.server.InstanceServerListener;
import com.kin207.netty.server.IServer;
import com.kin207.netty.session.SessionManagerAbs;

public class ServerListMessageHandle implements IMessageHandle<Object> {

	public String name() {
		return "/server/list";
	}

	public Class paramClass() {
		return null;
	}

	public void handle(Object param) {
		RequestContext req = RequestContext.curr.get();
		
		Collection<IServer> servers = req.getServer().getServerManager().getServers().values();
		StringBuffer msg = new StringBuffer();
		for(IServer item : servers){
			msg.append("name=").append(item.getName()).append("\t")
			.append("type=").append(item.getServerType()).append("\t")
			.append("port=").append(item.getPort()).append("\t")
			.append("sessions=").append(item.getSessionManager().sessions()).append("\n");
		}
		req.wirte(msg.toString());
		
	}

}
